package corpus;

/**
 * The methods expects either word or lemma and pos to be added.
 * 
 * If lemma and word exists, word takes priority.
 */
public class Word implements Comparable<Word> {
	private String word;
	private String pos;
	private String lemma;

	public Word(String word, String pos) {
		this.word = word;
		this.pos = pos;
	}
	
	public Word() {
	}

	public String toString() {
		if (word == null)
			return lemma + " " + pos;
		return word + " " + pos;
	}

	@Override
	public int hashCode() {
		if (word == null)
			return (lemma + pos).hashCode();
		return (word + pos).hashCode();
	}

	@Override
	public boolean equals(Object o) {
		Word w = (Word) o;
		if (word == null)
			return lemma.equals(w.lemma) && pos.equals(w.pos);
		return word.equals(w.word) && pos.equals(w.pos);
	}

	@Override
	public int compareTo(Word w1) {
		if (word == null)
			(lemma + pos).compareToIgnoreCase(w1.lemma + w1.pos);
		return (word + pos).compareToIgnoreCase(w1.word + w1.pos);
	}

	public String getWord() {
		return word;
	}

	public void setWord(String word) {
		this.word = word;
	}

	public String getPos() {
		return pos;
	}

	public void setPos(String pos) {
		this.pos = pos;
	}

	public String getLemma() {
		return lemma;
	}

	public void setLemma(String lemma) {
		this.lemma = lemma;
	}
}